package com.br.mercarad.projeto;

import java.io.File;



public class Projeto {
	
	private ProjetoVO rootProject;
	
	private String dirBase;
	
	public Projeto(String dirBase) {
		rootProject = new ProjetoVO();
		rootProject.setNomeTela("Root");
		this.dirBase = dirBase;

		listAllFiles(dirBase+"src\\com\\mercanet\\android\\domain", rootProject, true);
		System.out.println(rootProject);
	}
	
//	public FileVO getClasse(String nome, String pkg){
//		FileVO f = new FileVO();
//		File [] children = new File(dirBase).listFiles(); // list all the files in the directory
//		return f;
//	}
	
	public void listAllFiles(String directory, ProjetoVO parrentVO, Boolean recursive) {
		File [] children = new File(dirBase).listFiles(); // list all the files in the directory
		ProjetoVO projeto;
		for (int i = 0; i < children.length; i++) { // loop through each
			projeto = new ProjetoVO();
			//projeto.setParrentVO(parrentVO);
			
			projeto.setNomeTela(children[i].getName()); 
			parrentVO.addChild(projeto);
			
			if (children[i].isDirectory() && recursive) { 
				projeto.setTipo(1);
				listAllFiles(children[i].getPath(),projeto, recursive); // call again for the subdirectory
			} else if (!children[i].isDirectory()){ // otherwise, if it isn't a directory
				projeto.setTipo(0);
			}
			
		}
	}

	public ProjetoVO getRootProject() {
		return rootProject;
	}

	public void setRootProject(ProjetoVO rootProject) {
		this.rootProject = rootProject;
	}
	
		
}
